package com.eternallove.dao.system.model;

import com.eternallove.core.constants.Constants;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 系统定时任务
 * @author Eva.Caesar Liu
 * @since 2022/11/30 15:45
 */
@Data
@ApiModel("系统定时任务")
@TableName("`SYSTEM_JOB`")
public class SystemJob {

    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "主键", example = "1")
    @NotNull(message = "主键不能为空", groups = {Constants.OperaType.Update.class, Constants.OperaType.UpdateStatus.class})
    private Integer id;

    @ApiModelProperty(value = "JOB名称")
    @NotBlank(message = "任务名称不能为空", groups = {Constants.OperaType.Create.class, Constants.OperaType.Update.class})
    private String jobName;

    @ApiModelProperty(value = "JOB描述")
    private String jobDescription;

    @ApiModelProperty(value = "任务处理器类")
    @NotBlank(message = "任务处理器类不能为空", groups = {Constants.OperaType.Create.class, Constants.OperaType.Update.class, Constants.OperaType.UpdateStatus.class})
    private String handler;

    @ApiModelProperty(value = "数据分发处理器")
    private String distributeHandler;

    @ApiModelProperty(value = "分发数限制", example = "1")
    private Integer distributeLimit;

    @ApiModelProperty(value = "是否禁用并发执行")
    @NotNull(message = "是否禁用并发执行不能为空", groups = {Constants.OperaType.Create.class, Constants.OperaType.Update.class})
    private Boolean disallowConcurrent;

    @ApiModelProperty(value = "是否禁用")
    private Boolean disabled;

    @ApiModelProperty(value = "是否异步执行")
    @NotNull(message = "是否异步执行不能为空", groups = {Constants.OperaType.Create.class, Constants.OperaType.Update.class})
    private Boolean withAsync;

    @ApiModelProperty(value = "是否记录日志")
    @NotNull(message = "是否记录日志不能为空", groups = {Constants.OperaType.Create.class, Constants.OperaType.Update.class})
    private Boolean withLog;

    @ApiModelProperty(value = "CRON表达式")
    @NotNull(message = "CRON表达式不能为空", groups = {Constants.OperaType.Create.class, Constants.OperaType.Update.class})
    private String cronExpression;

    @ApiModelProperty(value = "服务器白名单")
    private String allowServerIps;

    @ApiModelProperty(value = "状态（0准备，1运行中）", example = "1")
    private Byte status;

    @ApiModelProperty(value = "锁编号", example = "1")
    private Integer lockNumber;

    @ApiModelProperty(value = "预计下一次执行时间")
    private Date nextFireTime;

    @ApiModelProperty(value = "创建人", example = "1")
    private Integer createUser;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date createTime;

    @ApiModelProperty(value = "更新人", example = "1")
    private Integer updateUser;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date updateTime;

    @ApiModelProperty(value = "是否删除")
    private Boolean deleted;

}
